package com.gao.pubsub.controller;

import com.gao.pubsub.service.ReceiverMessageService;
import com.gao.pubsub.util.RedisUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PublisherController {

    Logger logger = LoggerFactory.getLogger(PublisherController.class);

    @Autowired
    private RedisUtil redisUtil;

    @GetMapping(value = "pub")
    public String publishMessage(@RequestParam(name = "msg") String msg) {
        redisUtil.publish("pubsub", msg);
        logger.info("publishMessage send msg...");
        return "OK";
    }
}
